﻿#include "GLLInc.h"
#include "GLLException.h"

namespace GLL
{
	const char* GLLXcptStr = "XGLL-STD";

	bool Exception::IsGLLException( std::exception& e )
	{
		const char* what = e.what();
		const  int64 std_what = *((const  int64*)what);
		const int64 GLLXcpt = *((const int64*)GLLXcptStr);
		return std_what == GLLXcpt;
	}

	Exception::Exception( const char* what, const char* file, const char* func, int line ) 
		:_file(file), _func(func), _desc(what), std::exception(GLLXcptStr)
	{
		_line = line;
	}

	Exception::Exception( const String& what, const char* file, const char* func, int line )
		:_file(file), _func(func), _desc(what), std::exception(GLLXcptStr)
	{
		_line = line;
	}

	const char* Exception::what() const
	{
		StringStream strm;
		char Drive[10];
		char Path[256];
		char fileName[256];
		char postfix[10];
		_splitpath_s(_file, Drive, Path, fileName, postfix);
		strm << _desc << " -- (GameException)" << fileName << postfix << "("<< _line << ")";
		_desc = strm;
		return _desc.c_str();
	}

	void ShowExceptDesc( const char* type, std::exception &e ) 
	{
		StringStream strm;
		strm  << "(将本对话框截图发给何炜)\n\n" <<e.what() << "\n\n类型：" << type;
		Debug::osPopup.Show(strm, false);
	}

};
